package com.example.demo.config;

import com.example.demo.component.UserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-08-24
 * Time: 10:13
 */
@Configuration//不是Configurable！
public class AppConfig implements WebMvcConfigurer {

    @Autowired
    private UserInterceptor userInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/blog_login.html")//用queryString不影响
                .excludePathPatterns("/blog_detail.html")
                .excludePathPatterns("/blog_register.html")
                .excludePathPatterns("/blog_lists.html")
                .excludePathPatterns("/css/**")
                .excludePathPatterns("/editor.md/**")
                .excludePathPatterns("/img/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/user/picture")
                .excludePathPatterns("/blog_userImage/**")
                .excludePathPatterns("/user/register")
                .excludePathPatterns("/user/get_photo")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/art/detail")
                .excludePathPatterns("/art/all_list")
                .excludePathPatterns("/user/is_login")
        ;
    }

}
